var LicenseSelector = {
	getView : function(h, f) {
		var g = null;
		if (f) {
			var g = new Ext.grid.CheckboxSelectionModel({
				singleSelect : true
			});
		} else {
			g = new Ext.grid.CheckboxSelectionModel();
		}
		var b = new Ext.grid.ColumnModel({
			columns : [g, new Ext.grid.RowNumberer(), {
						header : 'id',
						dataIndex : 'id',
						hidden : true
					}, {
						header : '证照名称',
						dataIndex : 'licenseName'
					}, {
						header : '证照描述',
						dataIndex : 'licenseDesc'
					}],
			defaults : {
				sortable : true,
				menuDisabled : false,
				width : 100
			}
		});
		var c = new Ext.data.Store({
			proxy : new Ext.data.HttpProxy({
				url : __ctxPath + "/admin/listLicense.do"
			}),
			reader : new Ext.data.JsonReader({
				root : "result",
				totalProperty : "totalCounts",
				fields : [{
						name : 'id',
						type : 'int'
					}, 'licenseName', 'licenseDesc', 'createDate']
			}),
			remoteSort : true
		});
		var d = new Ext.grid.GridPanel({
			id : "LicenseSelectorGrid",
			width : 500,
			height : 300,
			region : "center",
			title : "证照列表",
			store : c,
			shim : true,
			trackMouseOver : true,
			disableSelection : false,
			loadMask : true,
			cm : b,
			sm : g,
			viewConfig : {
				forceFit : true,
				enableRowBody : false,
				showPreview : false
			},
			bbar : new Ext.PagingToolbar({
				pageSize : 25,
				store : c,
				displayInfo : true,
				displayMsg : "当前显示从{0}至{1}， 共{2}条记录",
				emptyMsg : "当前没有记录"
			})
		});
		c.load({
			params : {
				start : 0,
				limit : 25
			}
		});
		var a = new Ext.FormPanel({
			width : 500,
			region : "north",
			id : "LicenseForm",
			height : 40,
			frame : false,
			border : false,
			layout : "hbox",
			layoutConfig : {
				padding : "5",
				align : "middle"
			},
			defaults : {
				xtype : "label",
				margins : {
					top : 0,
					right : 4,
					bottom : 4,
					left : 4
				}
			},
			items : [{
						text : "查询条件:"
					}, {
						style : 'margin-top:5px;',
						xtype : 'label',
						text : '证照名称:'
					}, {
						name : 'Q_licenseName_S_LK',
						xtype : 'textfield'
					}, {
						xtype : "button",
						text : "查询",
						iconCls : "search",
						handler : function() {
							var i = Ext.getCmp("LicenseForm");
							var j = Ext.getCmp("LicenseSelectorGrid");
							if (i.getForm().isValid()) {
								i.getForm().submit({
									waitMsg : "正在提交查询",
									url : __ctxPath + "/admin/listLicense.do",
									success : function(l, m) {
										var k = Ext.util.JSON.decode(m.response.responseText);
										j.getStore().loadData(k);
									}
								});
							}
						}
					}]
		});
		var e = new Ext.Window({
			title : "证照选择器",
			iconCls : "menu-project",
			width : 530,
			height : 380,
			layout : "border",
			border : false,
			items : [a, d],
			modal : true,
			buttonAlign : "center",
			buttons : [{
						iconCls : "btn-ok",
						text : "确定",
						handler : function() {
							var n = Ext.getCmp("LicenseSelectorGrid");
							var o = n.getSelectionModel().getSelections();
							var id = "";
							var licenseName = "";
							var licenseDesc = "";
							for (var m = 0; m < o.length; m++) {
								if (m > 0) {
									id += ",";
									licenseName += ",";
									licenseDesc += ",";
								}
								id += o[m].data.id;
								licenseName += o[m].data.licenseName;
								licenseDesc += o[m].data.licenseDesc;
							}
							if (h != null) {
								h.call(this, id, licenseName, licenseDesc);
							}
							e.close();
						}
					}, {
						text : "取消",
						iconCls : "btn-cancel",
						handler : function() {
							e.close();
						}
					}]
		});
		return e;
	}
};